package com.beep.erp.model.home;

import com.beep.erp.common.bean.BizGoodsListBean;
import com.beep.erp.common.bean.ClassifyBean;
import com.beep.erp.common.bean.StockInDetailBean;
import com.beep.erp.http.HttpExceptionHandle;
import com.beep.erp.http.HttpResultSubscriber;
import com.beep.erp.model.stockIn.stockindetail.StockInDetailContract;

import rx.schedulers.Schedulers;

/**
 * Created by Jolly on 2018/9/2.
 */

public class HomePresenter extends HomeContract.Presenter {
    @Override
    public void getBizGoods(String sign, String timeStamp, int pageSize, int pageNo, String classify, String searchKey) {
        mRxManage.add(mModel.getBizGoods(sign, timeStamp, pageSize, pageNo, classify, searchKey).unsubscribeOn(Schedulers.io()).subscribe(new HttpResultSubscriber<BizGoodsListBean>() {
            @Override
            public void onError(HttpExceptionHandle.ResponeThrowable e) {
                mView.hideLoading();
                mView.showMessage(e.ErrorInfo);
            }

            @Override
            public void onNext(BizGoodsListBean bizGoodsListBean) {
                mView.hideLoading();
                mView.getBizGoods(bizGoodsListBean);
            }
        }));
    }

    @Override
    public void getGoodsClassify(String sign, String timeStamp, String type) {
        mRxManage.add(mModel.getGoodsClassify(sign, timeStamp, type).unsubscribeOn(Schedulers.io()).subscribe(new HttpResultSubscriber<ClassifyBean>() {
            @Override
            public void onError(HttpExceptionHandle.ResponeThrowable e) {
                mView.hideLoading();
                mView.showMessage(e.ErrorInfo);
            }

            @Override
            public void onNext(ClassifyBean classifyBean) {
                mView.hideLoading();
                mView.getGoodsClassify(classifyBean);
            }
        }));
    }

    @Override
    public void onStart() {
    }

}
